<?php
class PageCtrl{
	public $page_sum=0;//总页数
	public $mes_rows=0;//总记录数
	public $page_rows=2;//每页记录数
	public $corrent_page;
	public function __construct($page_rows,$corrent_page=null){
		if($corrent_page==null){
			$this->corrent_page=1;
		}else{
			$this->corrent_page=$corrent_page;
		}
		$this->page_rows=$page_rows;
	}
	public function echoPage(){
		$pagenext=$this->pageDown($this->corrent_page, $this->page_sum);
		$pagefront=$this->pageUp($this->corrent_page);
		//echo "mainpage.php"."?".$_SERVER['QUERY_STRING'];
		if(empty($_GET['querystr'])){
			$url="mainpage.php?require={$_GET['require']}";
		}else{
			$url="mainpage.php?require={$_GET['require']}&querystr={$_GET['querystr']}";
		}
		echo "<div>
		<span>共 {$this->mes_rows}条记录</span>
		<span>共{$this->page_sum}页</span>
		<span>当前第 {$this->corrent_page}页</span>
		<span><a href='{$url}&page={$pagefront}'>上一页</a></span>
		<span><a href='{$url}&page={$pagenext}'>下一页</a></span>
		</div>";
	}
	private function pageUp($corrent_page){
	if($this->corrent_page!=1){
	$this->corrent_page--;
	}
	return $this->corrent_page;
}
private function pageDown($corrent_page,$page_sum){
if($this->corrent_page!=$this->page_sum){
$this->corrent_page++;
}
return $this->corrent_page;;
}
}

?>